{{include file="../Common/head.html"}}
<div class="container">
    <button type="button" class="btn btn-default  btn-block" data-toggle="modal" data-target=".bs-example-modal-sm-add">添加班级</button>
    <table class="table table-hover">
        <tr>
            <th>班级编号</th>
            <th>班级名称</th>
            <th>操作</th>
        </tr>
        {{foreach from="$data" key=k item=v}}
        <tr>
            <td>{{$v.cid}}</td>
            <td>{{$v.cname}}</td>
            <td>
                <a href="index.php?m=Admin&c=Stu&cid={{$v.cid}}" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-wrench"></span></a>
                <button onclick="edit(this,{{$v.cid}})" cname="{{$v.cname}}" type="button" class="btn btn-success btn-xs" data-toggle="modal" data-target=".bs-example-modal-sm-edit"><span class="glyphicon glyphicon-check"></span></button>

                <button onclick="del({{$v.cid}})" type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target=".bs-example-modal-sm-del"><span class="glyphicon glyphicon-remove"></span></button>
            </td>
        </tr>
        {{/foreach}}

    </table>
</div>
<!--添加班级模态框-->
<form method="post" action="">
    <div class="modal fade bs-example-modal-sm-add "tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">添加班级</h4>
                </div>
                <div class="modal-body">
                        <div class="form-group">
                            <label for="exampleInputEmail1">班级名称</label>
                            <input type="text" class="form-control" name="cname" id="exampleInputEmail1" placeholder="请输入">
                        </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">返回首页</button>
                    <button type="submit" class="btn btn-primary">添加</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</form>
<!--编辑班级模态框-->
<form method="post" action="index.php?m=Admin&a=edit" id="edit">
    <div class="modal fade bs-example-modal-sm-edit "tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">编辑班级</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label for="exampleInputEmail1">班级名称</label>
                        <input type="text" class="form-control" name="cname" id="exampleInputEmail1" placeholder="请输入">
                        <input type="hidden" name="cid" value=""/>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">返回首页</button>
                    <button type="submit" class="btn btn-primary">编辑</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</form>
<!--删除-->
<form method="post" action="index.php?m=Admin&a=del" id="del">
    <div class="modal fade bs-example-modal-sm-del "tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">删除班级</h4>
                </div>
                <input type="hidden" name="cid" value=""/>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
                    <button type="submit" class="btn btn-primary">Yes</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</form>
<!--退出登录-->
<form method="post" action="index.php?m=Admin&a=del" id="out">
    <div class="modal fade bs-example-modal-sm-out "tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">退出登录</h4>
                </div>
                <input type="hidden" name="cid" value=""/>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
                    <button type="submit" class="btn btn-primary">Yes</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</form>
</body>
</html>
<script type="text/javascript">
    //编辑
    function edit(obj,cid) {
        //获取班级的旧名称
        var cname = $(obj).attr("cname");
        $("#edit").find("input[name=cname]").val(cname);
        $("#edit").find("input[type=hidden]").val(cid);
        $("#edit").modal('show');
    }
    function del(cid) {
        $("#del").find("input[type=hidden]").val(cid);
        $('#del').modal('show')
    }

</script>